<html>
<head><meta charset="utf-8"><title>impl Termination for Future · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html">impl Termination for Future</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203249453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203249453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203249453">(Jul 08 2020 at 09:58)</a>:</h4>
<p>Would negative impls allow expressing <code>impl !Future for () {}</code> (guarantee Future will never be implemented for unit)?</p>
<p>I have an almost working implementation of <code>impl Termination for Future</code> that is failing because I can't guarantee that Future will never be implemented for unit. I believe this is because Termination is defined in std, while Future is defined in core, which causes coherence issues.</p>



<a name="203249581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203249581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203249581">(Jul 08 2020 at 10:00)</a>:</h4>
<p>Mostly interested in identifying which feature(s) would be required to enable this impl, and so far I think it's negative impls? But not sure, so figured I'd ask.</p>



<a name="203249825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203249825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203249825">(Jul 08 2020 at 10:03)</a>:</h4>
<p>could we move <code>Termination</code> to core?</p>



<a name="203249913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203249913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203249913">(Jul 08 2020 at 10:04)</a>:</h4>
<p>Termination depends on "ExitCode" which is std-only iirc</p>



<a name="203249923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203249923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203249923">(Jul 08 2020 at 10:04)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> maybe? -- I'm using <code>std::thread</code> inside of my impl though, which I think means this issue would still persist</p>



<a name="203250009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250009">(Jul 08 2020 at 10:06)</a>:</h4>
<p>For reference; this is the code I'm trying to get to work: <a href="https://github.com/rust-lang/rust/compare/master...yoshuawuyts:future-termination">https://github.com/rust-lang/rust/compare/master...yoshuawuyts:future-termination</a></p>



<a name="203250210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250210">(Jul 08 2020 at 10:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125254">kennytm</span> <a href="#narrow/stream/213817-t-lang/topic/negative.20impls/near/203249913">said</a>:</p>
<blockquote>
<p>Termination depends on "ExitCode" which is std-only iirc</p>
</blockquote>
<p>it is implemented for <code>ExitCode</code>, so that's not the issue</p>



<a name="203250216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250216">(Jul 08 2020 at 10:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="211722">Yoshua Wuyts</span> <a href="#narrow/stream/213817-t-lang/topic/negative.20impls/near/203249923">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="124288">oli</span> maybe? -- I'm using <code>std::thread</code> inside of my impl though, which I think means this issue would still persist</p>
</blockquote>
<p>ah yes, that won't work</p>



<a name="203250239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250239">(Jul 08 2020 at 10:09)</a>:</h4>
<p>So... maybe we can use specialization here? as any concrete impl will be stronger than the generic impl</p>



<a name="203250455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250455">(Jul 08 2020 at 10:11)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> :O</p>



<a name="203250545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250545">(Jul 08 2020 at 10:12)</a>:</h4>
<p>I am never able to recall specialization syntax. Try slapping a <code>default</code> on the generic trait impl..</p>



<a name="203250553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250553">(Jul 08 2020 at 10:13)</a>:</h4>
<p>are there any examples of how to do that? Never used specializations before so not sure where to start</p>



<a name="203250566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250566">(Jul 08 2020 at 10:13)</a>:</h4>
<p>Oh cool; will try!</p>



<a name="203250698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250698">(Jul 08 2020 at 10:14)</a>:</h4>
<p>oh, apparently you don't even need the <code>default</code></p>



<a name="203250718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250718">(Jul 08 2020 at 10:15)</a>:</h4>
<p>just <code>#![feature(specialization)]</code> on the crate and it will magically work</p>



<a name="203250728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250728">(Jul 08 2020 at 10:15)</a>:</h4>
<p>that's scary</p>



<a name="203250782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250782">(Jul 08 2020 at 10:15)</a>:</h4>
<p>ah, use <code>#![feature(min_specialization)]</code> for less scaryness</p>



<a name="203250796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250796">(Jul 08 2020 at 10:15)</a>:</h4>
<p>(though still no <code>default</code> keyword needed)</p>



<a name="203250858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250858">(Jul 08 2020 at 10:16)</a>:</h4>
<p>hmm, <code>std</code> already has <code>min_specialization</code> enabled, and with that the error I'm getting still appears</p>



<a name="203250937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203250937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203250937">(Jul 08 2020 at 10:17)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error[E0119]: conflicting implementations of trait `process::Termination` for type `()`:
    --&gt; src\libstd\process.rs:1704:1
     |
1670 |   impl Termination for () {
     |   ----------------------- first implementation here
...
1704 | / default impl&lt;T, F&gt; Termination for F
1705 | | where
1706 | |     T: Termination,
1707 | |     F: Future&lt;Output = T&gt;,
...    |
1753 | |     }
1754 | | }
     | |_^ conflicting implementation for `()`
     |
     = note: upstream crates may add a new impl of trait `core::future::Future` for type `()` in future versions
</code></pre></div>



<a name="203251069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251069">(Jul 08 2020 at 10:18)</a>:</h4>
<p>hmm I was trying <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=97f7f0834f9607bb7249c4506967f662">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=97f7f0834f9607bb7249c4506967f662</a> but I realize now that this wasn't representing your setup</p>



<a name="203251115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251115">(Jul 08 2020 at 10:19)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=394482e2d6b0320fdfafa55bf9df583c">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=394482e2d6b0320fdfafa55bf9df583c</a> is the correct version...</p>



<a name="203251148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251148">(Jul 08 2020 at 10:19)</a>:</h4>
<p>both are the same link?</p>



<a name="203251217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251217">(Jul 08 2020 at 10:20)</a>:</h4>
<p>oops, updated</p>



<a name="203251242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251242">(Jul 08 2020 at 10:20)</a>:</h4>
<p>I find it very odd that we can specialize if the upstream crate <em>has</em> an impl, but not if it <em>hasn't</em></p>



<a name="203251326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251326">(Jul 08 2020 at 10:22)</a>:</h4>
<p><em>nods</em></p>



<a name="203251376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251376">(Jul 08 2020 at 10:22)</a>:</h4>
<p>I mean... the reasoning in the error is that adding a new impl will cause conflicts, so we already bail out without an impl. But the whole point about specialization is that the new impl does not conflict</p>



<a name="203251405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251405">(Jul 08 2020 at 10:22)</a>:</h4>
<p>so either we're missing a very subtle point in trait resolution, or this is just a bug^TM</p>



<a name="203251553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251553">(Jul 08 2020 at 10:24)</a>:</h4>
<p>Fingers crossed it's just a bug heh. Should we file an issue for this?</p>



<a name="203251565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251565">(Jul 08 2020 at 10:25)</a>:</h4>
<p>looking right now for pre-existing issues</p>



<a name="203251579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251579">(Jul 08 2020 at 10:25)</a>:</h4>
<p>hah; way ahead of me :P</p>



<a name="203251582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251582">(Jul 08 2020 at 10:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/213817-t-lang/topic/impl.20Termination.20for.20Future/near/203250210">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="125254">kennytm</span> <a href="#narrow/stream/213817-t-lang/topic/negative.20impls/near/203249913">said</a>:</p>
<blockquote>
<p>Termination depends on "ExitCode" which is std-only iirc</p>
</blockquote>
<p>it is implemented for <code>ExitCode</code>, so that's not the issue</p>
</blockquote>
<p><a href="https://github.com/rust-lang/rust/issues/43301#issuecomment-354303128">https://github.com/rust-lang/rust/issues/43301#issuecomment-354303128</a> ok the actual reason is the <code>eprintln!</code> inside the impl for <code>Result&lt;!, E&gt;</code>.</p>



<a name="203251691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251691">(Jul 08 2020 at 10:27)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/45542">https://github.com/rust-lang/rust/issues/45542</a></p>



<a name="203251830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203251830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203251830">(Jul 08 2020 at 10:29)</a>:</h4>
<p>Interesting; it sounds like there's good reason for this restriction?</p>



<a name="203252377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203252377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203252377">(Jul 08 2020 at 10:35)</a>:</h4>
<p>sounds to me like we just need the correct impl work</p>



<a name="203252409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203252409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203252409">(Jul 08 2020 at 10:36)</a>:</h4>
<blockquote>
<p>we should be able to make this work by reasoning through "potential specialization" along the same lines that we have an understanding of "potential overlap" today (potential overlap being what triggers an overlap error in the first place).</p>
</blockquote>



<a name="203265831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203265831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203265831">(Jul 08 2020 at 13:20)</a>:</h4>
<p>So, if you wanted to make a "specializable" impl, it would written like so:</p>
<div class="codehilite"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">F</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Termination</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">F</span><span class="w"></span>
<span class="k">where</span><span class="w"> </span><span class="n">F</span>: <span class="nc">Future</span><span class="o">&lt;</span><span class="n">Output</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">T</span><span class="o">&gt;</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">default</span> <span class="k">fn</span><span class="w"> </span><span class="n">report</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">i32</span> <span class="p">{</span><span class="w"> </span><span class="cm">/* default goes on the fn! */</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>This indicates that some other impl may swap in a more specialized <code>report</code> function.</p>



<a name="203265847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203265847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203265847">(Jul 08 2020 at 13:20)</a>:</h4>
<p><code>default impl</code> is something else, for better or worse</p>



<a name="203266045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203266045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203266045">(Jul 08 2020 at 13:22)</a>:</h4>
<p>However, this is indeed a complex case in specialization -- where <code>()</code> doesn't <em>today</em> specialize that base impl -- but conceivably it could in the <em>future</em> -- but only sometimes -- anyway suffices to say it would take some careful thought to decide when/if it's ok, though I think it ought to be.</p>



<a name="203266103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Termination%20for%20Future/near/203266103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Termination.20for.20Future.html#203266103">(Jul 08 2020 at 13:23)</a>:</h4>
<p>That said, something impl <code>impl !Future for ()</code> could conceivably help. I do have a desire to permit that and to integrate it into coherence so that coherence would just know that these two impls are not overlapping.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>